﻿<UserControl x:Class="Snipps.Views.EditTagView"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
             xmlns:i="clr-namespace:System.Windows.Interactivity;assembly=System.Windows.Interactivity"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
             xmlns:Controls="clr-namespace:Snipps.Controls" xmlns:l="clr-namespace:Snipps.Langs"
             xmlns:Behaviors="clr-namespace:Snipps.Infrastructure.Behaviors"
             d:DesignHeight="300"
             d:DesignWidth="300"
             mc:Ignorable="d">

    <UserControl.InputBindings>
        <KeyBinding Key="S"
                    Command="{Binding SaveCommand}"
                    Modifiers="Control" />
        <KeyBinding Key="Escape"
                    Command="{Binding CancelCommand}" />
    </UserControl.InputBindings>

    <Grid>

        <Grid.RowDefinitions>
            <RowDefinition Height="Auto" />
            <RowDefinition Height="Auto" />
            <RowDefinition Height="Auto" />
        </Grid.RowDefinitions>

        <Controls:BusyTextBox Grid.Row="0"
                              Text="{Binding TagName,
                                             NotifyOnValidationError=True,
                                             UpdateSourceTrigger=PropertyChanged}"
                              WatermarkText="{x:Static l:Lang.WatermarkEditTagName}">


            <i:Interaction.Behaviors>
                <Behaviors:BindableFocusBehavior FocusProperty="{Binding TagNameIsActive, Mode=TwoWay}" />
            </i:Interaction.Behaviors>
        </Controls:BusyTextBox>

        <Grid Grid.Row="1">
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="*" />
                <ColumnDefinition Width="*" />
            </Grid.ColumnDefinitions>
            <Button x:Name="btnSave"
                    Grid.Column="0"
                    Command="{Binding SaveCommand}"
                    Content="{x:Static l:Lang.BtnSave}">
                <i:Interaction.Behaviors>
                    <Behaviors:BindableFocusBehavior FocusProperty="{Binding SaveButtonActive.IsActive, Mode=TwoWay}" />
                </i:Interaction.Behaviors>
            </Button>

            <Button Grid.Column="1"
                    Command="{Binding CancelCommand}"
                    Content="{x:Static l:Lang.BtnCancel}">
                <i:Interaction.Behaviors>
                    <Behaviors:BindableFocusBehavior FocusProperty="{Binding CancelButtonActive.IsActive, Mode=TwoWay}" />
                </i:Interaction.Behaviors>
            </Button>

        </Grid>
        <TextBlock Grid.Row="2"
                   Style="{StaticResource ErrorTextBlockStyle}"
                   Text="{Binding ValidationSummary,
                                  NotifyOnValidationError=True,
                                  UpdateSourceTrigger=PropertyChanged}" />
    </Grid>
</UserControl>